home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / stat.zip / DYNAMIC.PAS < prev    next >
Pascal/Delphi Source File  |  1990-07-21  |  970b  |  37 lines

  1. program dynamic;
  2.  
  3. uses
  4.    crt,stat;
  5.  
  6. const
  7.      num = 2000;                       { number of data points }
  8. var
  9.    x       : single_array_pointer;     { point to the dynamic array }
  10.    j       : word;
  11.    sd      : single;
  12.    save,save2,save3  : longint;
  13. begin
  14.  
  15. { clear screen }
  16.      clrscr;
  17.      gotoxy(20,5);
  18.      writeln('DYNAMIC ARRAY CREATION AND DELETION EXAMPLE');
  19.  
  20. { save status of heap }
  21.      save := maxavail;
  22.  
  23. { create the dynamic x array and save memory used }
  24.      create_single_array(num,x);
  25.      save2 := maxavail;
  26.  
  27. { should be 8000 bytes used }
  28.      gotoxy(1,10);
  29.      writeln('actual and estimated ', (save - save2 ):10, num*sizeof(single):10,
  30.           ' bytes used in x array');
  31.      delete_single_array(num,x);
  32.      save3 := maxavail;
  33.      writeln((save3 - save2 ):10,' bytes recovered from heap');
  34.  
  35. { answers below should be the same }
  36.      writeln('Before use and after example heap size',save:10,save3:10);
  37. end.